<template>
	<view>
		<view class="list gray">设置你在本群的昵称</view>
		<view class="list list1">
			<input type="text" v-model="name" />
			<image class="guanbi" @click="guanbi" src="../../static/image/guanbi.png"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '123',
				group_id:''

			}
		},
		onShow() {
			this.$msgchat.initwork();
		},
		onLoad(options){
			this.group_id = options.group_id;
			this.name = options.myname;
			// this.initDat();
			// uni.onSocketMessage(function (res) {
			//   console.log('收到服务器内容：' + res.data);
			// });
		},
		methods: {
			//初始化数据
			initDat(){
				var obj = {
					token: uni.getStorageSync('token'),
					group_id:this.group_id,
					note:this.name
				}
				this.$common.requests('/api/Group/editmygroupnote', obj).then(res => {
					console.log(res)
					if(res.data.code==1){
						this.$api.msg(res.data.msg);
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/groupDetails/groupDetails?group_id='+this.group_id
							})
						}, 800)
					}else{
						this.$api.msg(res.data.msg);
						return;
					}
					
				})
			},
			guanbi() {
				this.name = '';
			}

		},
		onNavigationBarButtonTap(e) {
			this.initDat();
		}
	}
</script>

<style>
	page {
		background: #F5F4F9;
	}

	.list {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30upx;
		letter-spacing: 3upx;
	}

	.gray {
		color: #787878;
	}

	.list1 {
		background: #FFF;
	}

	.guanbi {
		width: 40upx;
		height: 40upx;
	}

	input {
		width: 85%;
	}
</style>
